import { CombatEvent } from "@/Battle/Event/CombatEvent.js";
export class CombatEventPool{
    /**
     * @type {CombatEvent[]}
     */
    static events=[];

    static newCombatEvent(type,launcher,payload,reason){
        let event=null;
        if(this.events.length>0){
            event=this.events.shift();
            event.reset(type,launcher,payload,reason);
        }else{
            event=new CombatEvent(type,launcher,payload,reason);
        }
        return event;
    }

    /**
     * 
     * @param {CombatEvent} event 
     */
    static releaseCombatEvent(event){
        if(!event||this.events.indexOf(event)>=0)return;
        event.reset(null,null,null,null);
        this.events.push(event);
    }

    static clear(){
        this.events.length=0;
    }
}